#include "reg52.h"


unsigned char led_num[12];
unsigned char led_cs8[8];
unsigned char led_data[8];


int delay(unsigned time)
{
 	int i ;
	int j ;

	for(i = 0 ; i < time ; i ++)
	{
	    for(j = 0 ; j < 100 ; j ++)	// j = j + 1  ; j ++;
		{

		}
			
	}
}


void main()
{
	unsigned int i ;
	unsigned int j ;
	unsigned int k ;
	led_num[0]= 0x3f;
	led_num[1]= 0x06;
	led_num[2]= 0x5B;
	led_num[3]= 0x4f;
	led_num[4]= 0x66;
	led_num[5]= 0x6d;
	led_num[6]= 0x7d;
	led_num[7]= 0x07;
	led_num[8]= 0x7f;
	led_num[9]= 0x6f;
	led_num[10]= 0x00;
	led_num[11]= 0x80;

	led_cs8[0] = (0x00 << 2);
	led_cs8[1] = (0x01 << 2);
	led_cs8[2] = (0x02 << 2);
	led_cs8[3] = (0x03 << 2);
	led_cs8[4] = (0x04 << 2);
	led_cs8[5] = (0x05 << 2);
	led_cs8[6] = (0x06 << 2);
	led_cs8[7] = (0x07 << 2);

	led_data[7]= 10;
	led_data[6]= 10;
	led_data[5]= 10;
	led_data[4]= 10;
	led_data[3]= 10;
	led_data[2]= 10;
	led_data[1]= 10;
	led_data[0]= 10;


	i = 0 ;
	j = 0 ; 
	k = 0 ;
	while(1)
	{
		P2 = led_cs8[i] ;

		P0 = led_num[led_data[i]];  //0000 0001
		i ++ ;
		j ++ ;
		if (i > 7)
		{
		 	i = 0;
		}
		if(j > 500)
		{
			k ++ ;
			led_data[0] = k % 10;
			led_data[1] = (k / 10) % 10;
			led_data[2] = (k / 100) % 10;
			
			j = 0;
		}
		delay(2);
		
	}
}		